package com.easy.admin.system.test;

import sun.plugin2.util.SystemUtil;

import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * @author wangbo
 * @deprecated niosocket客户端
 */
public class NioSocketclient {

    public static void main(String[] args) throws  Exception{
        SocketChannel channel = SocketChannel.open();
        channel.configureBlocking(false);
        InetSocketAddress addree = new InetSocketAddress("127.0.0.1",9090);
        if (!channel.connect(addree)){
            while(!channel.finishConnect()){
                System.out.println("链接中。。。。。");
            }

        }
        ByteBuffer by = ByteBuffer.wrap("hello".getBytes());
        channel.write(by);

        System.in.read();
    }
}
